#include "gserver.h"

gserver::gserver(QObject *parent) : QObject(parent) {
	
	//setup the tcp server
	serv = new GTcpServer(this);
	if(!serv->listen(QHostAddress::Any, 21000)) {
		exit(0);
		cout<<"error setting up tcp server" <<endl;
	}
	
	//setup the console reader
	reader = new GConsoleReader(this);
	connect(reader, SIGNAL(signalQuit()), this, SLOT(signalQuit()));
	connect(reader, SIGNAL(signalQuit()), serv, SLOT(signalQuit()));
	reader->start();
	
}

gserver::~gserver() {
	delete serv;
}



void gserver::signalQuit() {
	cout<<"Goodbye" <<endl;
	sleep(1);
	exit(0);
}
